    /* global getCookie */
    /* global timeToTimestamp visitUrl*/
    /* global hex_md5 */

    function passwordIn () {
        var shopId = $("#shopId").val();
        var money = $("#money").val();

        if (shopId == ''){
            $.toast("没有店铺", "cancel");
            return;
        }
       
        if (money == ''){
            $.toast("金额不能为空", "cancel");
            return;
        }
        if (money < 500){
            $.toast("金额最低500元", "cancel");
            return;
        }


        $.modal({
            title: "请输入支付密码",
            text: '<input class="weui-input weui-prompt-input" type="password" id="password"  placeholder="请输入支付密码" />',
            buttons: [
              { text: "取消", className: "default" },
              { text: "确定", onClick: function(){
                if ($("#password").val() == '') {
                    $.toast("密码不能为空", "cancel");
                    return;
                }
                submitAdd($("#password").val());
               } }
              
            ]
          });
        
    }
    function submitAdd(password){
        var shopId = $("#shopId").val();
        var money = $("#money").val();
        
        var params = {};
        params.id = shopId;
        params.money = money;
        params.token = getCookie('token');
        var time = timeToTimestamp(new Date());
        var passwords = hex_md5(password).toUpperCase();
        params.payPass = hex_md5(passwords + time).toUpperCase();
        params.time = time;

        $.ajax({
            type:'POST',
            url:"/antique/api/mallShop/manage/update_shop_margin_auth",
            data: params,
            dataType:"json",
            success:function(res){
                if (res.code == 0){
                     /* global isMiniProgram wx */
                    if ( isMiniProgram () ) {//小程序
                        wx.miniProgram.redirectTo({
                            url: "/pages/auth_manage"
                        });
                    } else {
                        visitUrl(document.referrer);
                    }
                    $.toast("认证成功");
                 } else {
                    $.toast(res.message, "cancel");
                }
                
            }
        });
          

    } 

   


